<template>
	<view class="my-money">
		<view class="center_balance_flex" @click="balanceto(4)">
			<text>储备金</text>
			<text>{{user.reserve_money}}</text>
			<image src="https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/images/drop-down2.png" mode=""></image>
		</view>
		<view class="center_balance_flex" @click="balanceto(3)">
			<text>补贴</text>
			<text>{{user. mcbt}}</text>
			<image src="https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/images/drop-down2.png" mode=""></image>
		</view>
		<view class="center_balance_flex" @click="balanceto(2)">
			<text>积分</text>
			<text>{{user.jifen}}</text>
			<image src="https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/images/drop-down2.png" mode=""></image>
		</view>
		<view class="center_balance_flex" @click="balanceto(1)">
			<text>粮票</text>
			<text>{{user.user_money}}</text>
			<image src="https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/images/drop-down2.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {}
			}
		},
		onShow() {
			this.get_user_info()
		},
		methods: {
			//获取用户信息
			async get_user_info() {
				if (this.user_id > 0) {
					// post请求
					const data = await this.$post('api/UserInfo')
					if (data.code == 200) {
						this.user = data.data.user
					} else {
						this.$u.toast(data.msg)
					}
					setTimeout(() => {
						uni.stopPullDownRefresh()
					}, 500)
				} else {
					setTimeout(() => {
						uni.stopPullDownRefresh()
					}, 500)
				}
				this.$post('api/config')
			},
			//跳转到资金明细
			balanceto(type) {
				this.$u.route({
					url: '/pages/center/capital-list',
					params: {
						type
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.my-money {
		width: 95%;
		margin: 20rpx auto;

		.center_balance_flex {
			width: 100%;
			padding: 30rpx;
			background: #fff;
			border-radius: 20rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;
			font-size: 30rpx;
			text {
				padding-right: 20rpx;
			}
			image {
				margin-left: auto;
				width: 15rpx;
				height: 15rpx;
			}
		}
	}
</style>